package lei.h_java8特性;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjuster;
import java.time.temporal.TemporalAdjusters;
import java.util.Arrays;

/**
 * @className: 日期时间API
 * @author: xl
 * @date: 2025/3/1 15:13
 * @Version: 1.0
 * @description:
 */

public class 日期时间API {


    public static void main(String[] args) {

        LocalDate day =LocalDate.of(2025,4,21);

        System.out.println(day.getDayOfWeek());//星期一


        LocalDateTime.now().with(TemporalAdjusters.firstDayOfMonth());

        //格式化
        LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));

        // 获取当前年份
        LocalDateTime.now().getDayOfYear();//今年中的第几天


        // 冒泡排序
        int[] arr = {1, 5, 3, 2, 4};
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }

        System.out.println(Arrays.toString( arr));

    }
}

